package com.hamll.es.controller;


import com.hamll.es.pojo.RequestParams;
import com.hamll.es.service.ISearchService;
import com.hmall.common.dto.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/search")
public class SearchController {


    @Autowired
    private ISearchService service;


    @GetMapping("/suggestion")
    public List<String> suggestion(@RequestParam String key) throws IOException {
        return service.suggestion(key);
    }
    /**
     * 过滤筛选品牌和分类结果展示
     * @return
     */
    @PostMapping("/filters")
    public Map<String,List<String>> filters(@RequestBody RequestParams params) throws IOException {
        return service.filters(params);
    }

    /**
     * 基本搜索查询
     * @param params
     * @return
     */
    @PostMapping("/list")
    public PageResult list(@RequestBody RequestParams params) throws IOException {
        return service.list(params);
    }

}
